<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="/css/admin.css" rel="stylesheet" type="text/css" />
<script src="/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/js/ckfinder/ckfinder.js" type="text/javascript"></script>
<style type="text/css">
	.longtxt{width:300px;}
	.handimg{cursor:pointer;}
</style>
<script type="text/javascript">
	$(function () {	
		var thumburl = '<?=$thumbs?>';
		if(thumburl != ''){
			thumburl = thumburl.replace("/images/","/_thumbs/images/");
			$("#preview").html("<img src='" + thumburl + "' />");
			$("#preview").css('display','');
		}

		$("#ttype").val('<?=$ttype?>');
	});				

	function VerifyPage(){
		if($("#tname").val() == ''){
			alert('模板名称不能为空!');
			return false;
		}
		return true;
	}

	function MyGoBack(){ 
		window.location = "/cms/templates";		
	}

	function BrowseServer( ){		
		var finder = new CKFinder();
		//finder.startupPath = 'Images:/';		
		finder.selectActionFunction = SetFileField;
		//finder.selectActionData = 'titlethumbs';		
		//finder.selectThumbnailActionFunction = MyShowThumbnails;
		finder.popup();
	}

	function SetFileField( fileUrl ){
		//var sFileName = this.getSelectedFile().name;
		$("#thumbs").val(fileUrl);		
		var thumburl = fileUrl.replace("/images/","/_thumbs/images/");//fileUrl;//
		$("#preview").html('<img src="' + thumburl + '" />');
		$("#preview").css('display','');
	}

	function clearTitlethumb(){
		$("#thumbs").val('');
		$("#preview").html('');
		$("#preview").css('display','none');
	}
	
</script>
</head>
<body>
<form name="form1" action="/cms/savetpl" method="post" onSubmit="return VerifyPage();">
<input type="hidden" name="tid" value="<?=$tid ?>" />
<div class="listTitle">编辑模板</div>
<div>
<table cellpadding="5" width="100%">
<tr><td>类型</td><td><select id="ttype" name="ttype"><option value="0">首页模板</option><option value="1">栏目模板</option><option value="2">文档模板</option></select></td></tr>
<tr><td width="60" nowrap>模板名称</td><td><input type="text" class="longtxt" id="tname" name="tname" value="<?=$tname?>" /></td></tr>

<tr><td>描述</td><td><input type="text" class="longtxt" id="descr" name="descr" value="<?=$descr?>" /></td></tr>
<tr><td>内容</td><td><textarea id="tcontent" name="tcontent" rows="20" cols="5"  style="width:90%;"><?=$tcontent?></textarea></td></tr>
<tr><td>缩略图</td><td valign="middle"><span id="preview" style="display:none;"></span><a href="javascript:BrowseServer();">添加</a>&nbsp;&nbsp;<a href="javascript:clearTitlethumb()">清除</a><input type="hidden" id="thumbs" name="thumbs" value="<?=$thumbs?>" /></td></tr>
<tr><td></td><td><input type="submit" value=" 保存 " />&nbsp;&nbsp;<input type="button" value="返回" onclick="MyGoBack();" />&nbsp;&nbsp;<font color='#ff0000'><?=$tip?></font></td></tr>
</table>
</div>
</form>
</body>
</html>